/**
 * Created by Administrator on 2016/9/8.
 */
var map;
require([
    "esri/map",
    "esri/layers/FeatureLayer",
    "esri/InfoTemplate",
    "esri/symbols/SimpleFillSymbol",
    "esri/symbols/SimpleLineSymbol",
    "esri/graphic",
    "esri/dijit/InfoWindow",
    "esri/Color",
    "esri/SpatialReference",
    "esri/renderers/UniqueValueRenderer",
    "dojo/domReady!"
], function(
    Map,
    FeatureLayer,
    InfoTemplate,
    SimpleFillSymbol,
    SimpleLineSymbol,
    Graphic,
    InfoWindow,
    Color,
    spatialReference,
    UniqueValueRenderer
) {
    map = new Map("map",{
        basemap:"streets",
        center: [120.148,30.158],
        zoom: 15,
        slider: false
    });
    var template=new InfoTemplate("land~${ID}");

   var land = new FeatureLayer("http://192.168.1.157:8399/arcgis/rest/services/zhxtd/ground_plan/MapServer/2", {
        infoTemplate: template,
        mode: FeatureLayer.MODE_AUTO,
        outFields: ["*"]
    });

    var renderer =new UniqueValueRenderer(null,"DL");
    function createSymbol(color){
        return new SimpleFillSymbol( ).setColor(new Color(color))
    }

    renderer.addValue({
        value: "JZ",
        symbol: createSymbol([255, 255, 0]),
        label: "居住用地",
        description: "SW Florida"
    });
    renderer.addValue({
        value: "SZ",
        symbol: createSymbol([255, 223, 127]),
        label: "商住用地",
        description: "Northeast Florida"
    });
    renderer.addValue({
        value: "SY",
        symbol: createSymbol([255, 0,  0]),
        label: "商业用地",
        description: "Northeast Florida"
    });
    renderer.addValue({
        value: "GC",
        symbol: createSymbol([151, 151, 151]),
        label: "广场用地",
        description: "Northeast Florida"
    });
    renderer.addValue({
        value: "WT",
        symbol: createSymbol([255, 158, 129]),
        label: "文体用地",
        description: "Northeast Florida"
    });
    renderer.addValue({
        value: "LD",
        symbol: createSymbol([159, 255, 127]),
        label: "绿地",
        description: "Northeast Florida"
    });
    renderer.addValue({
        value: "GY",
        symbol: createSymbol([153, 95, 76]),
        label: "工业用地",
        description: "Northeast Florida"
    });
    renderer.addValue({
        value: "QT",
        symbol: createSymbol([165, 82, 124]),
        label: "其他用地",
        description: "Northeast Florida"
    });
    renderer.setVisualVariables([{
        type: "sizeInfo",
        field: "DL",
        valueUnit: "unknown",
        minSize: 0.75,
        maxSize: 8.25,
        minDataValue: 10,
        maxDataValue: 150000
    }]);

    land.setRenderer(renderer);

    map.addLayer(land);

    map.on("click", function(evt){

        map.centerAt(evt.mapPoint);

    });
});